function initFilterConditionsControl(t){var i=JSON.parse(t.data);if(i){window["filter_conditions_"+t.propertyID]=new FilterConditionsParameterControl(i,t)}}function FilterConditionsParameterControl(t,i){var e=BX.util.getRandomString(5);this.params=i||{};this.message=JSON.parse(i.propertyParams.JS_MESSAGES)||{};this.data=t||{};this.nodes={};this.ids={form:"limit_cond_form_"+this.params.propertyID+"_"+e,container:"limit_cond_container_"+this.params.propertyID+"_"+e,treeObject:"limit_cond_obj_"+this.params.propertyID+"_"+e};this.path=this.getPath();this.buildNodes();BX.addCustomEvent("onTreeConditionsInit",BX.proxy(this.modifyTreeParams,this));BX.addCustomEvent("onAdminTabsDeleteLevel",BX.proxy(this.onChangeForm,this));BX.addCustomEvent("onNextVisualChange",BX.proxy(this.onChangeForm,this));BX.addCustomEvent("onTreeCondPopupClose",BX.proxy(this.onChangeForm,this));BX.ajax({timeout:60,method:"POST",dataType:"html",url:this.path+"/ajax.php",data:{action:"init",condition:this.params.oInput.value,ids:this.ids,sessid:BX.bitrix_sessid()},onsuccess:BX.proxy(this.saveDataAfterInit,this)})}FilterConditionsParameterControl.prototype={getPath:function(){var t=this.params.propertyParams.JS_FILE.split("/");t.pop();return t.join("/")},deleteFromArray:function(t,i){if(!BX.type.isArray(t)||!BX.type.isArray(i))return;for(var e=i.length;--e;){if(!!i[e]&&i.hasOwnProperty(e)){if(BX.util.in_array(e,t)){i.splice(e,1)}}}},onChangeForm:function(){if(!this.nodes.form)return;BX.fireEvent(this.nodes.form,"change")},modifyTreeParams:function(t,i,e){if(!e)return;var o,r,n=[];for(o in e){if(e.hasOwnProperty(o)){r=e[o];if(r.group){this.modifyCondGroup(r)}else{if(this.modifyCondValueGroup(r)){n.push(o)}}}}this.deleteFromArray(n,e)},modifyCondGroup:function(t){var i;if(t.visual){for(i in t.visual.values){if(t.visual.values.hasOwnProperty(i)){if(t.visual.values[i].True==="False"){t.visual.values.splice(i,1);t.visual.logic.splice(i,1)}}}}if(t.control){for(i in t.control){if(t.control.hasOwnProperty(i)){t.control[i].dontShowFirstOption=true;if(t.control[i].id==="True"){delete t.control[i].values.False}}}}},modifyCondValueGroup:function(t){if(!t||!t.children||!t.children.length)return;var i="CondIBProp",e=["CondIBXmlID","CondIBSection","CondIBDateActiveFrom","CondIBDateActiveTo","CondIBSort","CondIBDateCreate","CondIBCreatedBy","CondIBTimestampX","CondIBModifiedBy","CondIBTags","CondCatQuantity","CondCatWeight"],o,r,n;for(var a in t.children){if(t.children.hasOwnProperty(a)){r=t.children[a];o=true;if(BX.util.in_array(r.controlId,e)){o=false}else{n=r.controlId.split(":");if(n[1]&&n[1]!=this.data.iblockId&&n[1]!=this.data.offersIblockId){return true}if(n[0]===i&&n[2]){o=false}}if(o){delete t.children[a]}}}t.children=t.children.filter(function(t){return t});return false},buildNodes:function(){this.nodes.warning=BX.create("DIV",{props:{className:"bx-filter-conditions-warning"},text:this.message.invalid,style:{display:"none",color:"red"}});this.nodes.container=BX.create("DIV",{props:{id:this.ids.container}});this.nodes.form=BX.create("FORM",{props:{id:this.ids.form,name:this.ids.form},children:[this.nodes.container],events:{change:BX.proxy(function(){this.saveData()},this)}});this.params.oCont.appendChild(BX.create("DIV",{children:[this.nodes.warning,this.nodes.form]}))},saveDataAfterInit:function(){setTimeout(BX.proxy(this.saveData,this),50)},saveData:function(){var t={action:"save",ids:this.ids,sessid:BX.bitrix_sessid()};BX.ajax({timeout:60,method:"POST",dataType:"json",url:this.path+"/ajax.php",data:BX.merge(this.getAllFormData(),t),onsuccess:BX.proxy(function(t){if(t===""){this.nodes.warning.style.display="block"}else{this.nodes.warning.style.display="none";this.params.oInput.value=JSON.stringify(t)}},this)})},getAllFormData:function(){var t=BX.ajax.prepareForm(this.nodes.form);for(var i in t.data){if(t.data.hasOwnProperty(i)&&i==""){delete t.data[i]}}return!!t&&t.data?t.data:{}}};
//# sourceMappingURL=script.map.js